﻿using PLC.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PLC.Manager
{
    public class EnvDataManagerSimpleFactory
    {
        static IEnvDataManager dataManager =null;

        /// <summary>
        /// 这里的创建的函数最好有单例模式，不然每个模块都要创建一个，不优雅。
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static IEnvDataManager createEnvDataManager(string type)
        {
            if (dataManager != null)
            {
                return dataManager;
            }
            else
            {
                //测试环境下
                if (type.ToLower().Equals("test"))
                {
                    dataManager = new TestEnvManager();
                    return dataManager;
                }

                //专门针对恒力泵业的
                if (type.ToLower().Equals("hl"))
                {
                    EnvDataManager envDataManager = new EnvDataManager();
                    envDataManager.init_hl();
                    dataManager = envDataManager;
                    return dataManager;
                }

                else
                {
                    EnvDataManager envDataManager = new EnvDataManager();
                    envDataManager.Init();
                    dataManager = envDataManager;
                    return dataManager;
                }    
            }
        }
    }
}
